package com.imooc.security.core.validate.code;

import java.time.LocalDateTime;

/**
 * @Author sherry
 * @Description
 * @Date Create in 2019-03-22
 * @Modified By:
 */

public class ValidateCode {
    private String code;
    //    过期时间点
    private LocalDateTime expireTime;

    public ValidateCode() {
    }

    /**
     * @param code
     * @param expireIn 有效时间，秒
     */
    public ValidateCode(String code, int expireIn) {
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }


    public boolean isExpired() {
        return LocalDateTime.now().isAfter(expireTime);
    }
}
